home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Collection of Tools & Utilities
/
Collection of Tools and Utilities.iso
/
tex
/
jemtex2.zip
/
JEM2TEX.PAS
< prev
next >
Wrap
Pascal/Delphi Source File
|
1991-04-14
|
41KB
|
1,210 lines
{$A-,B-,D-,E-,F-,I+,L-,N-,O-,R-,S-,V-}
{Compile with Turbo-Pascal 5.0}
Program Jem2TeX(Input,Output);
{
This program translates a .JEM file into a .TeX file
Author: Francois Jalbert
'
Date: November 1990
Version: 1.0
Date: January 1991
Version: 1.01
Modifications: - Added \hskip0pt plus0.1em between all Japanese symbols which
improved dramatically line breaks and inter-sentence spacing
since [La]TeX could only add glue between whole Japanese
sentences.
- Extra space after punctuation is now an option since it is
not desirable with MuTeX when the text is to go under the
staff.
- Font names now use only small letters to be compatible with
the fontlib program supplied with emTeX.
- Command line parameters now supported.
- Run-time parameters now supported.
- Updated and improved run-time messages.
Date: April 1991
Version: 2.00
Modifications: - Added four kanjis.
- If desired, only standard JIS '83 characters are allowed.
- If desired, a % is added at each Japanese end of line.
- Three file name extensions .JEM .JPN .JAP now supported.
- Default extension is .JEM and the program has been renamed.
- Three run-time parameter flags now supported.
- Japanese comments not translated anymore for reference.
- Hyphenation and glue handled separately for better control.
- More clever algorithm for Japanese hyphenation.
- Space after some punctuation now obtained with \eeee.
- Small space around some punctuation introduced with \eee.
- Tiny space between Japanese characters with \ee.
- Space between Japanese and Roman with \eeee and \eee.
- Symbols separated only by [La]TeX comments are now
recognized as consecutive.
- MS-kanji (Shift-JIS) now supported.
Error Levels: 0 - Normal termination.
1 - Error.
}
Const
{Highest Bitmap number in JIS24}
BitmapMax=7806;
{Highest font number}
FontMax=60; {Floor of 7806 Div 128}
{Highest size number}
SizeMax=7; {magsteps are 0, 0.5, 1, 2, 3, 4, 5}
{File name extensions in priority order}
Extension1:String[4]='.jem';
Extension2:String[4]='.jpn';
Extension3:String[4]='.jap';
{Run-time flag of all the same length}
RunFlag1:String[7]='JEM2TEX';
RunFlag2:String[7]='JPN2TEX';
RunFlag3:String[7]='JAP2TEX';
{Parameter flag}
Flag1='/'; {DOS style}
Flag2='-'; {UNIX style}
{Parameter keywords in approximate decreasing length order}
Space1:String[10]='EXTRASPACE';
Space2:String[5]='EXTRA';
Space3:String[5]='SPACE';
NoSpace1:String[12]='NOEXTRASPACE';
NoSpace2:String[7]='NOEXTRA';
NoSpace3:String[7]='NOSPACE';
Percent1:String[7]='COMMENT';
Percent2:String[7]='PERCENT';
Percent3:String[3]='EOL';
NoPercent1:String[9]='NOCOMMENT';
NoPercent2:String[9]='NOPERCENT';
NoPercent3:String[5]='NOEOL';
EUC1:String[3]='EUC';
NoEUC1:String[7]='MSKANJI';
NoEUC2:String[8]='SHIFTJIS';
Extended1:String[8]='EXTENDED';
Standard1:String[8]='STANDARD';
LaTeX1:String[5]='LATEX';
TeX1:String[5]='MUTEX';
TeX2:String[3]='TEX';
One1:String[4]='1000';
Two1:String[4]='1095';
Three1:String[4]='1200';
Four1:String[4]='1440';
Five1:String[4]='1728';
Six1:String[4]='2074';
Seven1:String[4]='2488';
One2:String[3]='0.0';
Two2:String[3]='0.5';
Three2:String[3]='1.0';
Four2:String[3]='2.0';
Five2:String[3]='3.0';
Six2:String[3]='4.0';
Seven2:String[3]='5.0';
One3:String[1]='0';
Three3:String[1]='1';
Four3:String[1]='2';
Five3:String[1]='3';
Six3:String[1]='4';
Seven3:String[1]='5';
Type
InFileType=File Of Byte;
OutFileType=Text;
BitmapRange=1..BitmapMax;
FontRange=0..FontMax;
FontType=Array [FontRange] Of Boolean;
SizeRange=1..SizeMax;
FontsType=Array [SizeRange] Of FontType;
{Run time parameters}
RunTimeType=Record
FileName,Extension:String;
ExtraSpace,Percent,LaTeX,EUC,Extended:Boolean;
Size:SizeRange;
End;
{Japanese punctuation information}
PunctuationType=Record
{Indicates .,!? present}
OldMajorEOL,NewMajorEOL:Boolean;
{Indicates :; present}
OldMinorEOL,NewMinorEOL:Boolean;
{Indicates `"([< and other openings present}
OldOpening,NewOpening:Boolean;
{Indicates '")]> and other closings present}
OldClosing,NewClosing:Boolean;
{Indicates Japanese center dot present}
OldCenterDot,NewCenterDot:Boolean;
{Indicates Hiragana, Katakana, or Kanji present}
OldJapanese,NewJapanese:Boolean
End;
{Scanning Information}
ScanningType=Record
{Current pass terminated}
Done:Boolean;
{Indicates the current pass must produce output}
Echo:Boolean;
{Indicates the current line is a comment}
Comment:Boolean;
{Indicates current Bitmap immediately followed previous one}
Immediate:Boolean;
{Indicates the last Roman character was a letter or digit}
WasLetter:Boolean;
{Used for glue after a bitmap and before a roman}
RomanMajorEOL,RomanMinorEOL,RomanOpening:Boolean;
{Non-comment Bitmap found}
Found:Boolean;
{Processing the first character on the line which could be %}
First:Boolean;
{Comment line which may contain Bitmaps}
CommentLine:String;
{Current JIS24 Bitmap number}
Bitmap:BitmapRange;
{Roman or first part of Bitmap read}
Data1:Byte
End;
Var
{Input and Output file names}
InFile:InFileType;
OutFile:OutFileType;
{Run time parameters}
RunTime:RunTimeType;
{JemTeX fonts used}
Fonts:FontsType;
{------------------------------ EchoParameters -------------------------------}
Procedure EchoParameters(Var EchoFile:Text; Var RunTime:RunTimeType);
{Echoes the current parameters in EchoFile}
Begin
With RunTime Do
Begin
Write(EchoFile,'File='+FileName);
If ExtraSpace Then Write(EchoFile,' Space')
Else Write(EchoFile,' No Space');
If Percent Then Write(EchoFile,' Added %')
Else Write(EchoFile,' No Added %');
If LaTeX Then Write(EchoFile,' LaTeX')
Else Write(EchoFile,' TeX');
If EUC Then Write(EchoFile,' EUC')
Else Write(EchoFile,' MS-kanji');
If Extended Then Write(EchoFile,' Extended')
Else Write(EchoFile,' Standard');
Write(EchoFile,' Font Size=');
Case Size Of
1:Write(EchoFile,'1000');
2:Write(EchoFile,'1095');
3:Write(EchoFile,'1200');
4:Write(EchoFile,'1440');
5:Write(EchoFile,'1728');
6:Write(EchoFile,'2074');
7:Write(EchoFile,'2488')
End;
Writeln(EchoFile,'.')
End
End;
{------------------------------- GetParameters -------------------------------}
Procedure SimpleQuery(Title,ChoiceA,ChoiceB:String; Var Answer:Boolean);
Var
JChar:Char;
Valid:Boolean;
Begin
Repeat
Valid:=True;
Writeln(Title+':');
Writeln(' a) '+ChoiceA);
Writeln(' b) '+ChoiceB);
Write('Your choice? ');
Readln(JChar);
JChar:=UpCase(JChar);
If JChar='A' Then Answer:=True
Else
If JChar='B' Then Answer:=False
Else
Begin Valid:=False; Write(Chr(7)) End
Until Valid;
Writeln
End;
Procedure SizeQuery(Var Size:SizeRange)